//
//  HMMainViewController.swift
//  Weibo28
//
//  Created by 范英强 on 16/3/21.
//  Copyright © 2016年 范英强. All rights reserved.
//

import UIKit

class HMMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let tabBar = HMTabBar()
        //self.tabBar = tabBar 系统控件 只读的
        // 可以通过KVC设置

        
        setValue(tabBar, forKey: "tabBar")
        
        addChildViewController(HMHomeTableViewController(), imgName: "tabbar_home", title: "首页")
        addChildViewController(HMMessageTableViewController(), imgName: "tabbar_message_center", title: "消息")
        addChildViewController(HMDiscoverTableViewController(), imgName: "tabbar_discover", title: "发现")
        addChildViewController(HMProfileTableViewController(), imgName: "tabbar_profile", title: "我")

    }
    
    func addChildViewController(vc:UIViewController,imgName: String, title: String){
        // 设置title
//        vc.tabBarItem.title = title
//        vc.navigationItem.title = title
        vc.title = title
        // 设置image
        vc.tabBarItem.image = UIImage(named: imgName)
        vc.tabBarItem.selectedImage = UIImage(named: "\(imgName)_selected")
        
        addChildViewController(UINavigationController(rootViewController: vc))
    }

}
